<?php
$allowedExts = array("jpg", "jpeg", "gif");
for($i =0;$i<7;$i++)
{

$extension = end(explode(".", $_FILES["file"]["name"][$i]));
$extension = strtolower($extension);


if ((($_FILES["file"]["type"][$i] == "image/gif")
|| ($_FILES["file"]["type"][$i] == "image/jpeg")
|| ($_FILES["file"]["type"][$i] == "image/pjpeg")
&& ($_FILES["file"]["size"][$i]/1024 < 2000))
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["file"]["error"][$i] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"][$i] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"][$i] . "<br />";
    echo "Type: " . $_FILES["file"]["type"][$i] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"][$i] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"][$i] . "<br />";
	list($width,$height)=getimagesize($_FILES["file"]["tmp_name"][$i]);
    echo "w-h file: " . $width ."-". $height. "<br />";
	
	
    if (file_exists("../../data1/images/" . ($i+1).".".$extension))
      {
		  $src;
	if($extension=="jpg" || $extension=="jpeg" )
	{
	$uploadedfile = $_FILES['file']['tmp_name'][$i];
	$src = imagecreatefromjpeg($uploadedfile);
	
	}
	else if($extension=="png")
	{
	$uploadedfile = $_FILES['file']['tmp_name'][$i];
	$src = imagecreatefrompng($uploadedfile);
	
	}
	else 
	{
	$src = imagecreatefromgif($uploadedfile);
	}

		 
	 


	list($width,$height)=getimagesize($uploadedfile);

	$newwidth=288;
	$newheight=90;
	$tmp=imagecreatetruecolor($newwidth,$newheight);
	$newwidth1=960;
	$newheight1=300;
	$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
	imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
	imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
	
	$filename = "../../data1/tooltips/". ($i+1).".".$extension;
	$filename1 = "../../data1/images/". ($i+1).".".$extension;
	
	imagejpeg($tmp,$filename,100);
	imagejpeg($tmp1,$filename1,100);

	  echo"=============";
	  imagedestroy($src);
	imagedestroy($tmp);
	imagedestroy($tmp1);
      }
   
    }
  }
else
  {
  //echo "Invalid file";
  }
  
  
}header("Location: ../banner.php");
?>